<template>
  <div class="container-preview">
    <div class="box" v-for="(item, index) in list" :key="index">
      <div class="article-header">
        <h2 v-if="item.id === id" class="btnhh">{{ item.title }}</h2>
        <div class="info">
          <span v-if="item.id === id">{{ item.createTime | parseTimeByString }}</span>
          <span v-if="item.id === id">{{ item.username }}</span>
          <span v-if="item.id === id" icon="el-icon-view"></span>
          <span v-if="item.id === id">{{ item.visits }}</span>
        </div>
      </div>
      <div class="article-content" v-html="item.articleBody" v-if="item.id === id"></div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'containerPreview',
  props: {
    list: {
      type: [Array, Object],
      required: true
    },
    id: {
      type: [String, Number],
      required: true
    }
  }
}
</script>

<style scoped lang='scss'>
.container-preview {
  .box {
    width: 760px;
    .article-header {
      .info {
        margin: 10px 0 20px 0;
        span {
          padding: 10px;
        }
      }
    }
    .article-content {
      box-sizing: border-box;
      // height:290px;
      padding: 10px;
      background-color: #f5f5f5;
      max-width: 100%;
      border-top: 1px dotted gray;
    }
  }
}
</style>
